dnl Process this file with autoconf to produce a configure script.
# Copyright (C) 2000-2012, 2016, 2019 Free Software Foundation, Inc.
# Copyright (C) 2020, 2021 Maxime Devos
#
# Author (GnuTLS): Nikos Mavrogiannopoulos, Simon Josefsson
# Author (scheme-GNUnet): Maxime Devos
#
# This file is part of scheme-gnunet
#
# scheme-GNUnet is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or (at
# your option) any later version.
#
# scheme-GNUnet is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with scheme-GNUnet.  If not, see <http://www.gnu.org/licenses/>.

# This file is partially based upon the Autoconf script of GnuTLS.
# Not all scheme-GNUnet code is licensed as GPL, some is licensed as AGPL.

AC_PREREQ([2.61])
AC_INIT([scheme-gnunet], [0], [])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIRS([m4])

AM_INIT_AUTOMAKE([foreign subdir-objects])

AC_MSG_RESULT([***
*** Checking for compilation programs...
])
dnl Checks for programs.
#PKG_PROG_PKG_CONFIG

dnl GNU Guile support
AC_MSG_CHECKING([whether building the Scheme implementation])
AC_ARG_ENABLE(guile,
        AS_HELP_STRING([--enable-guile], [build GNU Guile implementation]),
                [opt_guile_impl=$enableval], [opt_guile_impl=yes])
AC_MSG_RESULT($opt_guile_bindings)

AC_ARG_WITH([guile-site-dir], AS_HELP_STRING([--with-guile-site-dir=DIR],
    [guile site directory for scheme-gnunet, default is guile system settings]),
    [guilesitedir="${withval}"], [guilesitedir='$(GUILE_SITE)'])
AC_ARG_WITH([guile-site-ccache-dir], AS_HELP_STRING([--with-guile-site-ccache-dir=DIR],
    [guile ccache directory for scheme-gnunet, default is guile system settings]),
    [guilesiteccachedir="${withval}"], [guilesiteccachedir='$(GUILE_SITE_CCACHE)'])
AC_SUBST([guilesitedir])
AC_SUBST([guilesiteccachedir])

if test "$opt_guile_impl" = "yes"; then
   AC_MSG_RESULT([***
*** Detecting GNU Guile...
])

   dnl Check for 'guild', which can be used to compile Scheme code
   dnl on Guile 2.x and 3.x.
   AC_PATH_PROG([GUILD], [guild])
   AC_SUBST([GUILD])

   dnl TODO check if 2.x works
   GUILE_PKG([3.0 2.2 2.0])
   GUILE_PROGS
   GUILE_SITE_DIR
   GUILE_FLAGS
fi

AM_CONDITIONAL([HAVE_GUILE], [test "$opt_guile_bindings" = "yes"])
AM_CONDITIONAL([HAVE_GUILD], [test "x$GUILD" != "x"])

AC_OUTPUT([Makefile])
